<?php $this->load->view('common/header');?>
<style>
    *{
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    html,body{
        width: 100%;
        height: 100%;
    }
    body{
        max-width: 640px;
        min-width: 320px;
        overflow-x: hidden;
        margin: 0 auto;
    }
    .clearfix:after {
        content: "";
        display: block;
        visibility: hidden;
        height: 0;
        clear: both;
    }
    .clearfix {
        zoom: 1;
    }
    .main{
        width: 100%;
        height: 105%;
        background: url(<?php echo $viewmulu;?>images/bg.jpg) no-repeat;
        -webkit-background-size: cover;
        background-size: cover;
    }
    .user_menu2 li span i.ico_d {
        background-position: -110px -22px;
    }
</style>
<body>
<div class="main login">
    <div class="item-wrap">
        <div class="logo">
            <img src="<?php echo $viewmulu; ?>images/logo.png">
            <p style="font-weight: bold;color: white">请输入销售好友联系方式</p>
        </div>
        <div class="label user_menu2">
            <ul>
                <li>
            	<span class="input">
                	<i class="ico ico_d"></i>
                	<input placeholder="请输入好友称呼" id="name">
                </span>
                </li>
                <li>
            	<span class="input">
                	<i class="ico ico_a"></i>
                	<input placeholder="请输入手机号码" id="mobile">
                </span>
                </li>
            </ul>
            <div class="nav_box" style="margin-top: 20px">
                <a href="javascript:;" style="background-color: goldenrod" id="doLogin">立即提交</a>
            </div>
        </div>
    </div>
</div>
<script>
    // 提交
    $("#doLogin").on("click",function(){

        var mobile = $("#mobile").val();
        var name = $("#name").val();
        var myreg = /^((\d{3}-\d{8}|\d{4}-\d{7,8})|(1[3|5|7|8][0-9]{9}))$/;
        if (mobile=="") {
            layer.msg('请填写手机号码');
            return false;
        }
        if (name=="") {
            layer.msg('请填写好友称呼');
            return false;
        }
        if(!myreg.test(mobile)){
            layer.msg("手机号格式不正确");
            return false;
        }
        var URL= baseurl+"index.php/member/recommend";
        $.ajax({
            type: "post",
            url: URL,
            dataType:'json',
            data: {
                'mobile':mobile,
                'name':name,
                'csrf_test_name': ci_csrf_token()
            },
            success: function(data){
                if(data.code == 1){
                    layer.msg('恭喜，推荐一位好友成功', {
                        time: 1000, //1s后自动关闭
                        shade: 0.1
                    },function () {
                        window.location.href = window.location.href;
                    });
                }else{
                    layer.msg(data.info);
                    return false;
                }

            }
        });
    });
</script>
</body>
</html>
